#!/usr/bin/env python2
import random
import string
import hashlib
import sys
import getopt
import string
MAX_LEN=44

def render(len=MAX_LEN, num_flag=True, low_flag=True, up_flag=True, special_flag=True):
 num = "0123456789"
 lower = "abcdefghijklmnopqrstuvwxyz"
 upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 special = "~!@#$%^&*()[]{}_=+-"

 str = ''
 if num_flag:
   str += num
 if low_flag:
   str += lower
 if up_flag:
   str += upper
 if special_flag:
   str += special
 if str == '':
   str = num + lower
 return string.join(random.sample(str, len)).replace(" ", "")

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hf:a:n:v", ["help", "output=","add=","num="])
    except getopt.GetoptError, err:
        # print help information and exit:
        print str(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)
    output = None
    verbose = False
    add_flag=''
    file_name=''
    len1=None
    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-f", "--output"):
            file_name = a
        elif o in ("-a", "--add"):
            add_flag = a
        elif o in ("-n", "--num"):
            len1 = string.atoi(a)
        else:
            assert False, "unhandled option"
    if file_name!='' :
        fileHandle = open ( file_name, 'rb' )  
        random.seed(hashlib.sha512(fileHandle.read()).hexdigest()+add_flag)
        fileHandle.close()
    i = 0
    while(i < 31):
        print render(len1)
        i += 1
def usage():
    print "hed"
if __name__ == '__main__':
    main()
